import { Component, OnInit, ViewEncapsulation } from '@angular/core';
import { User } from '../../models/User';
import { AuthService } from '../../service/AuthService';
import { AuthGuardService } from '../../service/AuthGuardService';

@Component({
    templateUrl: './homePage.html',
    styleUrls: ['./homePage.css'],
    encapsulation: ViewEncapsulation.None
})
export class HomePageComponent implements OnInit {
    user: User;
    isLogin: boolean;
  constructor(private authService: AuthService,
      private authGuardService: AuthGuardService
  ) {
  }
    ngOnInit() {
      this.authGuardService.checkLogin().subscribe((isLogin: boolean) => {
        this.isLogin = isLogin;
        if (this.isLogin) {
          this.user = this.authService.user;
        } else {
          this.user = {
            password: ''
          }
        }
      })
    }
}
